home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-29 | 6.8 KB | 164 lines | [TEXT/MPS ] |
- # NewOpen - replacement "Open" script supporting file backup and remember
-
- Set ScriptName "{0}" # save the script's name
- Set NFile "{#}" # get number of command line arguments
- If ({NFile} == 0)
- # no Command Line arguments - Open will use NewGetFile dialog box
- Set CmdStr "`Begin; NewGetFile -t TEXT; Set OpenStatus {Status}; End`" ≥≥ Dev:Null
- If ({OpenStatus} == 0)
- # a file was selected - try to open it
- Open {CmdStr} ∑∑ Dev:Null # invoke NewGetFile to select a filename
- Set OpenStatus {Status}
- If ({OpenStatus} == 0)
- # the Open was successful - perform the backup and remember chores
- ReadOnlyStatus "{Active}" ∑∑ Dev:Null # test if this is a read-only file
- If ({Status} == 0)
- Set LeafName "`ParseFileName -l "{Active}"`" # get the file's leafname
- Duplicate -y "{Active}" "{Backup}" ∑∑ "{Worksheet}" || Beep # create the Backup file
-
- # Delete all the old "Remember" backup files
- For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
- Delete "{i}"
- End # For i
- End # If {Status}
- Else
- Alert "{ScriptName}:∂nUnable to open the file {CmdStr}."
- End # If {OpenStatus}
- Else
- If ({OpenStatus} != 4)
- # an error occured that was not a user cancellation
- Alert "{ScriptName}:∂nUnable to continue due to NewGetFile error #{NewStatus}."
- End # If {OpenStatus}
- End # If {OpenStatus}
- Else
- Loop
- Break If ({NFile} <= 0) # exit if all arguments have been processed
- If (("{1}" == "-n") || ("{1}" == "-r") || ("{1}" == "-t"))
- # a command line option has been encountered
- If (("{2}" == "-n") || ("{2}" == "-r") || ("{2}" == "-t"))
- # a second command Line option has been encountered
- If (("{3}" == "-n") || ("{3}" == "-r") || ("{3}" == "-t"))
- # a third command line option has been encountered
- If ("{4}" != "")
- Set ShiftSize 4
- Open "{1}" "{2}" "{3}" ∑∑ Dev:Null
- Else
- Set ShiftSize 3
- Open "{1}" "{2}" "{3}" "{4}" ∑∑ Dev:Null
- End # If {4}
- Set OpenStatus {Status}
- If ({OpenStatus} == 0)
- # the Open was successful - perform the backup and remember chores
- ReadOnlyStatus "{Active}" ∑∑ Dev:Null # test if this is a read-only file
- If ({Status} == 0)
- If (("{1}" != "-n") && ("{2}" != "-n") && ("{2}" != "-n"))
- DeRez -only "'MPSR' (1006)" "{Worksheet}" > DeRez.tmp # get the standard print options from the Worksheet
- Rez -a -o "{Active}" DeRez.tmp # transfer to the target file
- Delete DeRez.tmp # delete the temporary file
- End # If {1}
- Set LeafName "`ParseFileName -l "{Active}"`" # get the file's leafname
- Duplicate -y "{Active}" "{Backup}" ∑∑ "{Worksheet}" || Beep # create the backup file
-
- # Delete all the old "Remember" backup files
- For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
- Delete "{i}"
- End # For i
- End # If {Status}
- Else
- # an error occured that was not a user cancellation
- Alert "{ScriptName}:∂nUnable to open file {4} with options {1} {2} {3}."
- End # If {OpenStatus}
- Shift {ShiftSize}
- Evaluate NFile -= {ShiftSize} # update the argument counter
- Else
- If ("{3}" != "")
- Set ShiftSize 3
- Open "{1}" "{2}" "{3}" ∑∑ Dev:Null
- Else
- Set ShiftSize 2
- Open "{1}" "{2}" ∑∑ Dev:Null
- End # If {3}
- Set OpenStatus {Status}
- If ({OpenStatus} == 0)
- # the Open was successful - perform the backup and remember chores
- ReadOnlyStatus "{Active}" ∑∑ Dev:Null # test if this is a read-only file
- If ({Status} == 0)
- If (("{1}" != "-n") && ("{2}" != "-n"))
- DeRez -only "'MPSR' (1006)" "{Worksheet}" > DeRez.tmp # get the standard print options from the Worksheet
- Rez -a -o "{Active}" DeRez.tmp # transfer to the target file
- Delete DeRez.tmp # delete the temporary file
- End # If {1}
- Set LeafName "`ParseFileName -l "{Active}"`" # get the file's leafname
- Duplicate -y "{Active}" "{Backup}" ∑∑ "{Worksheet}" || Beep # create the backup file
-
- # Delete all the old "Remember" backup files
- For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
- Delete "{i}"
- End # For i
- End # If {Status}
- Else
- # an error occured that was not a user cancellation
- Alert "{ScriptName}:∂nUnable to open file {3} with options {1} {2}."
- End # If {OpenStatus}
- Shift {ShiftSize}
- Evaluate NFile -= {ShiftSize} # update the argument counter
- End # If {3}
- Else
- If ("{2}" != "")
- Set ShiftSize 2
- Open "{1}" "{2}" ∑∑ Dev:Null
- Else
- Set ShiftSize 1
- Open "{1}" ∑∑ Dev:Null
- End # If {2}
- Set OpenStatus {Status}
- If ({OpenStatus} == 0)
- # the Open was successful - perform the backup and remember chores
- ReadOnlyStatus "{Active}" ∑∑ Dev:Null # test if this is a read-only file
- If ({Status} == 0)
- If ("{1}" != "-n")
- DeRez -only "'MPSR' (1006)" "{Worksheet}" > DeRez.tmp # get the standard print options from the Worksheet
- Rez -a -o "{Active}" DeRez.tmp # transfer to the target file
- Delete DeRez.tmp # delete the temporary file
- End # If {1}
- Set LeafName "`ParseFileName -l "{Active}"`" # get the file's leafname
- Duplicate -y "{Active}" "{Backup}" ∑∑ "{Worksheet}" || Beep # create the backup file
-
- # Delete all the old "Remember" backup files
- For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
- Delete "{i}"
- End # For i
- End # If {Status}
- Else
- # an error occured that was not a user cancellation
- Alert "{ScriptName}:∂nUnable to Open file {2} with option {1}."
- End # If {OpenStatus}
- Shift {ShiftSize}
- Evaluate NFile -= {ShiftSize} # update the argument counter
- End # If {2}
- Else
- Open "{1}" ∑∑ Dev:Null
- Set OpenStatus {Status}
- If ({OpenStatus} == 0)
- # the Open was successful - perform the backup and remember chores
- ReadOnlyStatus "{Active}" ∑∑ Dev:Null # test if this is a read-only file
- If ({Status} == 0)
- Set LeafName "`ParseFileName -l "{Active}"`" # get the file's leafname
- Duplicate -y "{Active}" "{Backup}" ∑∑ "{Worksheet}" || Beep # create the backup file
-
- # Delete all the old "Remember" backup files
- For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
- Delete "{i}"
- End # For i
- End # If {Status}
- Else
- # an error occured that was not a user cancellation
- Alert "{ScriptName}:∂nUnable to open file {1}."
- End # If {OpenStatus}
- Shift
- Evaluate NFile -= 1 # update the argument counter
- End # If {1}
- End # Loop
- End # If {NFile}
-
- # end of NewOpen